#! encoding=utf-8

import requests
from common import HOST
import traceback


def get(query, skip, limit):
    url = HOST + '/result'
    print "GET /result 查看识别结果 ..."
    ret = None
    try:
        ret = requests.session().get(url + '?query=' + query + '&skip=' + skip + '&limit=' + limit).content
    except:
        print traceback.format_exc()
    finally:
        print ret


def deleteHandle(handle_id):
    url = HOST + '/result/' + handle_id
    print "DELETE /result/{handle_id} 清空单个 Handle 的识别结果 ..."
    try:
        requests.session().delete(url)
    except:
        print traceback.format_exc()


def delete():
    url = HOST + '/result'
    print "DELETE /result 清空所有识别结果 ..."
    try:
        requests.session().delete(url)
    except:
        print traceback.format_exc()